//
//  RootViewController.m
//  Lovely Food
//
//  Created by 李经纬 on 15/11/27.
//  Copyright © 2015年 李经纬. All rights reserved.
//

#import "RootViewController.h"
#import "AppDelegate.h"
#import "Header.h"

@interface RootViewController ()<UITabBarControllerDelegate>

@end

@implementation RootViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    self.tabBar.backgroundColor = [UIColor blackColor];
    
    
    
    UIView *backView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 49)];
    backView.backgroundColor = [UIColor blackColor];
    [self.tabBar insertSubview:backView atIndex:0];
    self.tabBar.opaque = YES;
    
    // 列表
    ListViewController *listVC = [[ListViewController alloc] init];
    UINavigationController *listNC = [[UINavigationController alloc] initWithRootViewController:listVC];
    listNC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"美食" image:[[UIImage imageNamed:@"diancan"] imageWithRenderingMode: UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImage imageNamed:@"diancan1"] imageWithRenderingMode: UIImageRenderingModeAlwaysOriginal]];
    
    // 社区
    CommunityViewController *communityVC = [[CommunityViewController alloc] init];
    UINavigationController *communityNC = [[UINavigationController alloc] initWithRootViewController:communityVC];
    communityNC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"社区" image:[[UIImage imageNamed:@"wodepingjia"] imageWithRenderingMode: UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImage imageNamed:@"wodepingjia1"] imageWithRenderingMode: UIImageRenderingModeAlwaysOriginal]];
    
    // 照相
    TakePhotosViewController *takePhotosVC = [[TakePhotosViewController alloc] init];
    UINavigationController *takePhotosNC = [[UINavigationController alloc] initWithRootViewController:takePhotosVC];
    takePhotosNC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"" image:[[UIImage imageNamed:@"xiangjis"] imageWithRenderingMode: UIImageRenderingModeAlwaysOriginal]selectedImage:nil];
    
    
    // 附近
    NearbyViewController *nearbyVC = [[NearbyViewController alloc] init];
    UINavigationController *nearbyNC = [[UINavigationController alloc] initWithRootViewController:nearbyVC];
    nearbyNC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"附近" image:[[UIImage imageNamed: @"zhuyefaxian"] imageWithRenderingMode: UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImage imageNamed: @"zhuyefaxian1"] imageWithRenderingMode: UIImageRenderingModeAlwaysOriginal]];
    
    // 用户
    UserViewController *userVC = [[UserViewController alloc] init];
    UINavigationController *userNC = [[UINavigationController alloc] initWithRootViewController:userVC];
    
    
    userNC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"用户" image:[[UIImage imageNamed:@"wodezhanghao"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal ] selectedImage:[[UIImage imageNamed:@"wodezhanghao1"] imageWithRenderingMode: UIImageRenderingModeAlwaysOriginal]];
    
    self.viewControllers = @[listNC, nearbyNC, takePhotosNC, communityNC, userNC];
    
    self.delegate = self;
    
    
    
    
}

- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
    NSLog(@"%ld", tabBarController.selectedIndex);
    
    if (tabBarController.selectedIndex == 2) {
        
    }
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
